Skip to content

fix(frontend): replace Findings API response any with typed contract#1988

Open
SathvikaSingoti wants to merge 1 commit into
utksh1:mainfrom
SathvikaSingoti:fix/findings-response-type-1401
Open

fix(frontend): replace Findings API response any with typed contract#1988
SathvikaSingoti wants to merge 1 commit into
utksh1:mainfrom
SathvikaSingoti:fix/findings-response-type-1401

Conversation

@SathvikaSingoti

Copy link
Copy Markdown
Collaborator

Description

The Findings page cast the getFindings API response to any in its initial fetch and loadMore callbacks, which hid pagination/result shape mistakes from the type checker. getFindings already returns a typed FindingsResponse (with findings?: FindingRecord[]) in api.ts, so this PR traces that type through the Findings page instead of discarding it.

Related Issues

Closes #1401

Type of Change

  • Refactor / type safety (non-breaking, no behavior change)

How Has This Been Tested?

  • Replaced (data: any) with (data: FindingsResponse) in the initial fetch effect and removed the any-adjacent as Finding[] blind cast in loadMore.
  • FindingRecord.id is string | undefined (shared type used across many endpoints), while the page's local Finding type requires id: string. Rather than weakening either type, both fetch paths now filter out any finding missing a valid id before assigning state, since a finding without an id can't be selected, checked, or reviewed anyway. This is stricter/safer than the previous blind cast.
  • Ran npm run typecheck - passes with no errors.
  • Ran npm run test - 537/537 tests passing across 61 files.
  • Ran npm run build - builds clean.
  • Ran bash scripts/check-artifacts.sh origin/main - no tracked generated artifacts or cache files in the diff.

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type-tightening is good, but the new filter on finding.id === 'string' introduces a pagination bug. When a page contains only records without id, page never advances and hasMore stays true, causing the infinite-scroll effect to request the same page repeatedly.

Fix: advance page based on a successful page fetch, not on moreFindings.length > 0, or derive hasMore from API page metadata rather than rendered-item count after client-side filtering.

@utksh1 utksh1 added level:beginner 20 pts difficulty label for small beginner-friendly PRs type:refactor Refactor work category bonus label area:frontend Frontend React/UI work labels Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Frontend React/UI work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:refactor Refactor work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TYPESCRIPT] Replace Findings API response any with a typed response contract

2 participants